package org.apache.ibatis.sample;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.sample.param.QueryParam;
import org.apache.ibatis.sample.result.Sales;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

/**
 * 方便源码阅读
 *
 * @author xiezhicong xiezc@3vjia.com
 * @since 2021-06-24 16:26
 */

public class HelloMybatis {

  public static void main(String[] args)throws Exception {
    String resource = "mybatis-config.xml";
    InputStream inputStream = Resources.getResourceAsStream(resource);
    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
    SqlSession sqlSession = sqlSessionFactory.openSession();
    QueryParam param = new QueryParam();
    param.setId(3);
    Sales sales = (Sales) sqlSession.selectOne("org.apache.ibatis.sample.mapper.ISaleMapper.selectById", param);
    System.out.println(1111);
  }
}
